﻿using System.Windows;
using System.ComponentModel;

namespace ZTZP_BEMSS_WPF
{
    /// <summary>
    /// Form_Messagebox.xaml 的交互逻辑
    /// </summary>
    public partial class Form_Messagebox : Window, INotifyPropertyChanged
    {
        public Form_Messagebox()
        {
            InitializeComponent();
            DataContext = this;  // 设置 DataContext 为当前窗口，启用绑定
        }


        private string _message;
        public string Message
        {
            get { return _message; }
            set
            {
                if (_message != value)
                {
                    _message = value;
                    OnPropertyChanged(nameof(Message)); // 通知属性值改变
                }
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        // 你可以调用这个方法来设置消息内容
        public void SetMessage(string message)
        {
            Message = message;  // 设置 Message 属性，这样会自动更新绑定的控件
        }
        public void ShowMessageInfo(string title,string infoStr)
        {
            this.Title = title;
            this.SetMessage(infoStr);
            this.ShowDialog();//模态对话框
        }
    }
}
